package view.nn.com.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import view.nn.com.myapplication.utils.CountDown;

/**
 */
public class WelActivity extends Activity {

    private View pt;
    private CountDown countDown;
    private Animation animation;
    private Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.wel_layout);
        pt = findViewById(R.id.welc);
        intent = new Intent(WelActivity.this, MainActivity.class);
        TextView textView = (TextView) findViewById(R.id.txtCountDown);
        countDown = new CountDown(textView);
        countDown.excute(5);
        animation = AnimationUtils.loadAnimation(this, R.anim.anim_alpha);
        animation.setFillEnabled(true);
        animation.setFillAfter(true);
        pt.setAnimation(animation);
        pt.setClickable(true);
        pt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri uri = Uri.parse("http://www.baidu.com");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
            }
        });
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }

    public void onSkip(View view) {
        animation.reset();
        startActivity(intent);
        finish();
    }
}
